<?php
require_once('admin/kernel.inc');
require_once('common.inc');

$NEWS = new  kernel($DB, $MECCANO);
$NEWS->SetProperty('table=meccano_news;treedepend=yes;userdepend=yes');
$NEWS->SetParams('user='.$AUTH->user['id'].';mode=d-;count=no');

$vars = $NEWS->Get();

if($vars != false)
{
	if($id != false)
	{
		for($i=0, $t=count($vars); $i<$t;$i++)
		{
			if($vars[$i]['id'] == $id) break;
		}
		$SMARTY->assign('vars_big', array_slice($vars, $i, 3));
	} else
	{
		$SMARTY->assign('vars_big', array_slice($vars, 0, 3));
	}
	
	SmartyPaginate::setTotal(count($vars), $_SYS['meccano']['pid']);
	SmartyPaginate::setUrl($_SERVER['PHP_SELF'].'?cat='.$cat, $_SYS['meccano']['pid']);
	SmartyPaginate::setLimit('15', $_SYS['meccano']['pid']);
	@$SMARTY->assign('vars', array_slice($vars, SmartyPaginate::getCurrentIndex($_SYS['meccano']['pid']), SmartyPaginate::getLimit($_SYS['meccano']['pid'])));
	SmartyPaginate::assign($SMARTY, 'paginate', $_SYS['meccano']['pid']);
} else
{
	$SMARTY->assign('vars', false);
	$SMARTY->assign('vars_big', false);
}

$SMARTY->display('tl.index.tpl.html');
